/**

 @Name：glayer v1.0.0 Web弹层组件
 @Author：宫则章
 @License：MIT
    
 */

;!function(window, undefined){
"use strict";
	function Layer(){

	}
	Layer.prototype.alert = function(msg,callback){
		$('body').append($(`<div class="glayerwrap">
			<div class="glayer">
				<div class="glayertitle">
					信息
				</div>
				<div class="glayercontent">
					${msg}
				</div>
				<div class="glayerbtn">
					<a class="glayer-btn0">确定</a>
				</div>
			</div>
		</div>`))
		this.x()
		$('.glayer-btn0').click(function(){
			// $('.glayerwrap').remove()
			callback($('.glayerwrap'))
		})
	}
	Layer.prototype.confirm = function(){
		$('body').append($(`<div class="glayerwrap">
			<div class="glayer">
				<div class="glayertitle">
					信息
				</div>
				<div class="glayercontent">
					<input type="text" name="username" placeholder="用户名">
					<input type="text" name="phone" placeholder="手机号">
				</div>
				<div class="glayerbtn">
					<a class="glayer-btn0">确定</a>
				</div>
			</div>
		</div>`))
		this.x()
		$('.glayer-btn0').click(function(){
			// $('.glayerwrap').remove()
			if($('input[name="username"]').val()===''){
				alert('用户名不能为空')
				$('input[name="username"]').focus()
				return
			}
			if($('input[name="phone"]').val()===''){
				alert('手机号不能为空')
				$('input[name="phone"]').focus()
				return
			}
			callback($('.glayerwrap'))
		})
	}
	Layer.prototype.msg = function(){
		
	}
	Layer.prototype.background = function(){
		
	}
	Layer.prototype.x = function(){
		$('.glayer').append($('<span class="glayerx">x</span>'))
		$('.glayerx').click(function(){
			$('.glayerwrap').remove()
			console.log(1111)
		})
	}
	Layer.prototype.click = function(elm){
		$('body').on('click','.glayerx',function(){
			console.log()
		})
	}
	window.Layer = Layer;
}(window);